package com.df.excel_export.utils;

import org.springframework.context.ApplicationContext;

public class SpringContextUtil {
    public ApplicationContext context;
    public void  init(ApplicationContext context){
        this.context = context;
    }

    public <T> T getBean(Class<T> clazz){
        return context.getBean(clazz);
    }

    private SpringContextUtil(){}

    private  enum Singleton{
        SINGLETON;
        private SpringContextUtil contextUtil = new SpringContextUtil();
        public SpringContextUtil getInstance(){
            return contextUtil;
        }
    }

    public static SpringContextUtil getInstance(){
        return Singleton.SINGLETON.getInstance();
    }
}
